<?php


use Illuminate\Support\Facades\Route;
use SwooleTW\Http\Websocket\Facades\Websocket;

/*
|--------------------------------------------------------------------------
| Websocket Routes
|--------------------------------------------------------------------------
|
| Here is where you can register websocket events for your application.
|
*/

Websocket::on('connect', function ($websocket, $request) {
    $websocket->emit('connect', $request);
});

Websocket::on('disconnect', function ($websocket) {
    $websocket->push('disconnect');
});

Websocket::on('example', function ($websocket, $data) {
    $websocket->emit('message', $data);
});

Websocket::on('message', function ( $websocket, $data) {
    $websocket->emit('message', $data);
});

Websocket::on('open', function ($websocket, $request) {
    return 'hello world';
});
